Option Explicit

Dim strFolder1, strFolder2, strFolder3, objFolder, strUser, strDomain
Dim objShell, objApp, objFSO

Set objShell = CreateObject("Wscript.Shell")
Set objApp = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")

strFolder1 = objShell.ExpandEnvironmentStrings("%ProgramData%") & "\SharePoint Total Automation Toolkit"
strFolder2 = objShell.ExpandEnvironmentStrings("%ProgramData%") & "\SharePoint Total Automation Toolkit\Configuration Files"
strFolder3 = objShell.ExpandEnvironmentStrings("%ProgramData%") & "\SharePoint Total Automation Toolkit\Software"
strUser = "Users"

If Not objFSO.FolderExists(strFolder1) Then

    'Create the folder
    Set objFolder = objFSO.CreateFolder(strFolder1)

End If

If Not objFSO.FolderExists(strFolder2) Then

    'Create the folder
    Set objFolder = objFSO.CreateFolder(strFolder2)

End If

If Not objFSO.FolderExists(strFolder3) Then

    'Create the folder
    Set objFolder = objFSO.CreateFolder(strFolder3)

End If

If objFSO.FolderExists(strFolder2) Then

    ' Grant users access to the config files directory
    objApp.ShellExecute "icacls", Chr(34) & strFolder2 & Chr(34) & " /inheritance:d /grant " & strUser & ":(OI)(CI)F ", "", "runas", 0

    ' Remove the read-only attribute from the sample config files
    objApp.ShellExecute "Attrib", "-R " & Chr(34) & strFolder2 & "\*.*" & Chr(34) & " /S /D", "", "runas", 0

Else
    Wscript.Echo "Error: folder " & strFolder2 & " could not be created"

End If

If objFSO.FolderExists(strFolder3) Then

    ' Grant users access to the config files directory
    objApp.ShellExecute "icacls", Chr(34) & strFolder3 & Chr(34) & " /inheritance:d /grant " & strUser & ":(OI)(CI)F ", "", "runas", 0

    ' Remove the read-only attribute from the sample config files
    objApp.ShellExecute "Attrib", "-R " & Chr(34) & strFolder3 & "\*.*" & Chr(34) & " /S /D", "", "runas", 0

Else
    Wscript.Echo "Error: folder " & strFolder3 & " could not be created"

End If